/* eslint-disable multiline-ternary */
import moment from 'moment'

/* eslint-disable no-unused-vars */
export const columns = [
  {
    name: 'Date',
    sortable: false,
    minWidth: '10rem',

    cell: (row) => (
      <>
        <div style={{ fontWeight: 'bold' }}>
          {row?.start_date !== null
            ? moment.unix(row?.start_date).format('MM/DD/YYYY')
            : '--'}
        </div>
      </>
    )
  },

  {
    name: 'Time',

    sortable: false,
    minWidth: '15rem',
    cell: (row) => (
      <>
        <span>
          {moment(row?.start_time, 'HH:mm').format('hh:mm A') || '--'}{' '}
          <span className="px-1">-</span>
          {moment(row?.end_time, 'HH:mm').format('hh:mm A') || '--'}
        </span>
      </>
    )
  },
  {
    name: 'Location',
    sortable: false,
    cell: (row) => {
      return (
        <>
          {!!row?.telehealth ? (
            <span>
              Telehealth Link: <br></br>{' '}
              <a
                href={`https://${row?.telehealth_link}`}
                target="_blank"
                className="telehealth-link"
              >
                {row?.telehealth_link}
              </a>
              {/* Telehealth {!!row?.telehealth_zoom_id && '| Zoom Meeting'}
              {!!row?.telehealth_google_id && ' | Google Meet'} */}
            </span>
          ) : row?.booking !== null ? (
            <span>
              {row?.booking?.location?.name || `--`},{' '}
              {row?.booking?.room?.name || '--'}
            </span>
          ) : (
            <span>
              {`${row?.provider_location?.city || '--'},${
                row?.provider_location?.address || '--'
              },${row?.provider_location?.state || '--'},${
                row?.provider_location?.zipcode || '--'
              }`}
            </span>
          )}
        </>
      )
    },
    minWidth: '15rem'
  },
  {
    name: 'Total',

    sortable: false,
    cell: (row) => {
      const handleTimeDiff = (startTimes, endTimes) => {
        // start time and end time
        const startTime = moment(startTimes, 'HH:mm a')
        const endTime = moment(endTimes, 'HH:mm a')

        const hrs = moment.utc(endTime.diff(startTime)).format('H')

        return hrs
      }

      return (
        <div>
          <span>{handleTimeDiff(row.start_time, row.end_time) || '--'}</span>
          {parseInt(handleTimeDiff(row.start_time, row.end_time)) === 1 ? (
            <span className="pl-05px">hour</span>
          ) : (
            <span className="pl-05px">hours</span>
          )}
        </div>
      )
    }
  }
]
